from dao import Dao
from model.session import Session

class SessionDao(Dao):
    def __init__(self):
        """Arguments:
            collection --- string the name of the collection
        """
        Dao.__init__(self, Session)
        self.collection = 'sessions'

    def insert(self, s):
        """Save the object to collection
        Arguments:
            s --- The Model object
        """
        if isinstance(s, Session):
            # Insert except ID field, because ID will be automatically generated
            _dict = {}
            _dict['user_id'] = s.user_id;
            _dict['item_id'] = s.item_id;
            
            return self.db.insert(self.collection, _dict)
        return None
    
